﻿@{
    ViewBag.Title = "Quản trị nhóm người dùng";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<div class="content">
    <div class="clear"></div>
    <table style="width: 100%">
        <tr>
            <td style="height: 40px;">
                <div id="nav"><a href="/Group/Index" title="">@ViewBag.Title.ToUpper()</a></div>
            </td>
        </tr>
        <tr>
            <td style="">
                <div style="width: 90%;">
                    <div>
                        <div class="col-md-2" style="text-align:right;padding:4px 4px 4px 4px;">
                            Tên nhóm
                        </div>
                        <div class="col-md-4">
                            <input type="text" class="txtsearch TextBoxContent" style="width: 100% !important" id="input-appname" name="appname">
                        </div>
                        <div class="col-md-2" style="text-align: right; padding: 4px 4px 4px 4px;">
                            Mã nhóm
                        </div>
                        <div class="col-md-4">
                            <input type="text" class="txtsearch TextBoxContent" style="width: 100% !important" id="input-appcode" name="appcode">
                        </div>
                        <div class="col-md-2" style="text-align:right;padding:4px 4px 4px 4px;">
                            Tên ứng dụng
                        </div>
                        <div class="col-md-4">
                            @Html.DropDownList("App", new SelectList(ViewBag.lstApp, "value", "text", 0), new { @id = "input-code-app", @name = "code", @class = "SelectBoxContent", @placeholder = "" })
                        </div>
                        <div class="col-md-2" style="text-align:right;padding:4px 4px 4px 4px;">
                            Nhóm người dùng
                        </div>
                        <div class="col-md-4">
                            @Html.DropDownList("Type", new SelectList(ViewBag.lstType, "value", "text", 0), new { @id = "input-code-type", @name = "code", @class = "SelectBoxContent", @placeholder = "" })
                        </div>
                        <div class="col-md-2" style="text-align:right;padding:4px 4px 4px 4px; margin-top:5px;">
                            Trạng thái sử dụng
                        </div>
                        <div class="col-md-4" style="margin-top:5px;">
                            @Html.DropDownList("IsActive", new SelectList(ViewBag.lstStatus, "value", "text", 2), new { @id = "input-code", @name = "code", @class = "SelectBoxContent", @placeholder = "" })
                        </div>
                    </div>
                    <div>
                        <div style="height: 10px;"></div>
                        <div class="col-md-12">

                            <div style="padding-top: 10px; text-align: center">
                                <div class="col-md-12">
                                    <span class="input-group-btn">
                                        <button class="btn btn-primary" type="button" onclick="return btnSearchClick();">
                                            <span class="glyphicon glyphicon-search"></span>Tìm kiếm
                                        </button>

                                        <button type="button" id="app_add" style="margin-left: 10px;" class="btn btn-primary" value="Thêm mới"><span class="glyphicon glyphicon-plus"></span>Thêm nhóm</button>
                                    </span>
                                    </br>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="app-list">
                    @{
                        Html.RenderPartial("_GroupList");
                    }
                </div>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    function btnSearchClick() {
        OnCriteria(0);
    }
    $(document).ready(function () {
        $('#app_add').bind('click', function (event) {
            prepareCreateOrUpdate(-1, 'Thêm mới Nhóm người dùng');
        });
        $('#input-code').change(function () {
            OnCriteria(crrPageIndex);
        });
        $('#input-code-app').change(function () {
            OnCriteria(crrPageIndex);
        });
        $('#input-code-type').change(function () {
            OnCriteria(crrPageIndex);
        });
    });

    function prepareCreateOrUpdate(appId, dlgTitle) {
        $('#app-model-container')
              .load("/Group/actionPrepareCreateOrUpdateGroup", { appId: appId }, function () {
                  $(this).dialog({
                      draggable: true,
                      modal: true,
                      resizable: false,
                      width: 'auto',
                      title: dlgTitle,
                      minHeight: 75,
                      my: "center",
                      at: "center",
                      of: window,
                      buttons: [
                            {
                                text: "Lưu",
                                icons: {
                                    primary: "ui-icon-heart"
                                },
                                class: 'btn btn-primary',
                                click: function () {                                   
                                    if (save) {
                                        var result = save();
                                        if (result) $(this).dialog("destroy");
                                    }
                                }
                            },
                            {
                                text: "Đóng",
                                icons: {
                                    primary: "ui-icon-close"
                                },
                                class: 'btn btn-primary',
                                click: function () {
                                    $(this).dialog("destroy");
                                }

                            }
                      ]
                  });
              });
    }

    function prepareViewDetail(userId, dlgTitle) {
        $('#app-model-container')
              .load("/Group/actionPrepareListRoleByGroupId", { groupId: userId }, function () {
                  $(this).dialog({
                      draggable: true,
                      modal: true,
                      resizable: false,
                      width: 'auto',
                      title: dlgTitle,
                      minHeight: 75,
                      my: "center",
                      at: "center",
                      of: window,
                      buttons: [
                            {
                                text: "Đóng",
                                icons: {
                                    primary: "ui-icon-close"
                                },
                                class: 'btn btn-primary',
                                click: function () {
                                    $(this).dialog("destroy");
                                }

                            }
                      ]
                  });
              });
    }

    //$('#checkall').click(function () {
    //    var chk = $(this).is(':checked');
    //    var cnt = $('input[type=checkbox]', "#ctg_content_body").length;
    //    $('input[type=checkbox]', "#ctg_content_body").each(function () {
    //        if (chk) {
    //            $(this).attr('checked', 'checked');
    //        }
    //        else {
    //            $(this).removeAttr('checked');
    //        }
    //    });
    //});
</script>
